package com.baboba.rummy.card;

import java.util.Comparator;

public class CardComparator implements Comparator<Card> {

    @Override
    public int compare(Card card1, Card card2) {
            if (card1.getNumber() == 0)
                    return -1;
            
            if (card2.getNumber() == 0)
                    return 1;
            
            if (card1.getColor() == card2.getColor())
                    return card1.getNumber() - card2.getNumber();
            else{
                    return card1.getColor().ordinal() - card2.getColor().ordinal();
            }
    }

}